﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AlarmManagePlatform.UC
{
    internal partial class GasCircuitPara : UserControl
    {

        internal Model.DB.tb_ParaInfo ParaInfo { get; set; }

        internal float StdGasConcentration
        {
            get { return (float)tbStdGasConcentration.Value; }
            set {
                if (tbStdGasConcentration.Value != value)
                    tbStdGasConcentration.Value = value;
            }
        }

        internal float IndicatingValue
        {
            get { return float.Parse(tbIndicatingValue.Value); }
        }

        internal int WaitingTime
        {
            get { return tbWaitingTime.Value; }
            set {
                if (tbWaitingTime.Value != value)
                    tbWaitingTime.Value = value;
            }
        }

        internal GasCircuitPara()
        {
            InitializeComponent();

            tbIndicatingValue.ReadOnly = true;

            tbStdGasConcentration.DisplayFormat = "########.####";
            tbStdGasConcentration.Minimum = double.MinValue;
            tbStdGasConcentration.Maximum = double.MaxValue;
            tbStdGasConcentration.Event_ValueChanged += TbStdGasConcentration_Event_ValueChanged;

            tbWaitingTime.Minimum = 0;
            tbWaitingTime.Maximum = int.MaxValue;
        }

        private void TbStdGasConcentration_Event_ValueChanged(object sender, EventArgs e)
        {
            tbIndicatingValue.Value = Math.Round(tbStdGasConcentration.Value * (ParaInfo == null ? 1 : ParaInfo.ConversionFactor),ParaInfo.Prec).ToString();
        }
    }
}
